package com.chenfan.finance.utils;

import com.alibaba.fastjson.JSON;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;
import java.util.*;

public class TimeFormatUtil {

    public static SimpleDateFormat yyyyMMDate = new SimpleDateFormat("yyyyMM");
    public static SimpleDateFormat allDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    public static SimpleDateFormat yyyyMMddDate = new SimpleDateFormat("yyyyMMdd");
    public static String localDateTimeToString(LocalDateTime oldTime) {
        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        String localTime = null;
        if(null != oldTime){
            localTime = df.format(oldTime);
        }
        return localTime;
    }
    public static String localDateTimeToString(LocalDateTime oldTime,String format) {
        DateTimeFormatter df = DateTimeFormatter.ofPattern(format);
        String localTime = null;
        if(null != oldTime){
            localTime = df.format(oldTime);
        }
        return localTime;
    }




}
